import i18n from "@/locale";

const getCaption = (name) => {
    let search = (window.location.search.substr(1) || window.location.hash.split("?")[1]) || '';
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = search.match(reg);
    if (r != null) return unescape(r[2]);
    return '';
}
const channel = getCaption('channel')
const localeName = getCaption('locale')


// 外显名称
localStorage.setItem('appName', process.env["VUE_APP_NAME"])
// 实际产品名称
localStorage.setItem('productName', process.env["VUE_APP_PRODUCT_NAME"])
if (channel) {
    localStorage.setItem('channel', channel)
}
// 国际化
if (localeName) {
    i18n.global.locale = localeName
    localStorage.setItem('locale', localeName)
} else {
    const locale = process.env.NODE_ENV !== 'production' ? 'en_ph' : process.env["VUE_APP_LOCAL"]
    localStorage.setItem('locale', locale)
}
